package com.smarthealthcare.device.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smarthealthcare.common.annotation.Log;
import com.smarthealthcare.common.core.controller.BaseController;
import com.smarthealthcare.common.core.domain.AjaxResult;
import com.smarthealthcare.common.enums.BusinessType;
import com.smarthealthcare.device.domain.Manufacturer;
import com.smarthealthcare.device.service.IManufacturerService;
import com.smarthealthcare.common.utils.poi.ExcelUtil;
import com.smarthealthcare.common.core.page.TableDataInfo;

/**
 * 设备厂家Controller
 * 
 * @author fry
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/device/manufacturer")
public class ManufacturerController extends BaseController
{
    @Autowired
    private IManufacturerService manufacturerService;

    /**
     * 查询设备厂家列表
     */
    @PreAuthorize("@ss.hasPermi('device:manufacturer:list')")
    @GetMapping("/list")
    public TableDataInfo list(Manufacturer manufacturer)
    {
        startPage();
        List<Manufacturer> list = manufacturerService.selectManufacturerList(manufacturer);
        return getDataTable(list);
    }

    /**
     * 导出设备厂家列表
     */
    @PreAuthorize("@ss.hasPermi('device:manufacturer:export')")
    @Log(title = "设备厂家", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Manufacturer manufacturer)
    {
        List<Manufacturer> list = manufacturerService.selectManufacturerList(manufacturer);
        ExcelUtil<Manufacturer> util = new ExcelUtil<Manufacturer>(Manufacturer.class);
        util.exportExcel(response, list, "设备厂家数据");
    }

    /**
     * 获取设备厂家详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:manufacturer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(manufacturerService.selectManufacturerById(id));
    }

    /**
     * 新增设备厂家
     */
    @PreAuthorize("@ss.hasPermi('device:manufacturer:add')")
    @Log(title = "设备厂家", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Manufacturer manufacturer)
    {
        return toAjax(manufacturerService.insertManufacturer(manufacturer));
    }

    /**
     * 修改设备厂家
     */
    @PreAuthorize("@ss.hasPermi('device:manufacturer:edit')")
    @Log(title = "设备厂家", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Manufacturer manufacturer)
    {
        return toAjax(manufacturerService.updateManufacturer(manufacturer));
    }

    /**
     * 删除设备厂家
     */
    @PreAuthorize("@ss.hasPermi('device:manufacturer:remove')")
    @Log(title = "设备厂家", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(manufacturerService.deleteManufacturerByIds(ids));
    }
}
